#ifndef WiiNunchuck_h
#define WiiNunchuck_h

#include "WProgram.h"
#include <Wire.h>

class WiiNunchuck
{
public:

  // Public variables
  unsigned int xAnalog;
  unsigned int yAnalog;
  unsigned int xAccel;
  unsigned int yAccel;
  unsigned int zAccel;
  bool zButtonDown;
  bool cButtonDown;
  bool zButtonHit;
  bool cButtonHit;
  
  WiiNunchuck(int statusLED = 0, int cLED = 0, int zLED = 0);
  // power from analog pins
  void setPowerPins();
  // send the initilization handshake
  void init();
  int getData();
  
  float getAnalogX();
  float getAnalogY();
  float getAccelerationX();
  float getAccelerationY();
  float getAccelerationZ();
  
  float getXGs();
  float getYGs();
  float getZGs();
  void printData();
private:
  int _statusLED, _cLED, _zLED;
  byte nunchuck_buf[6];  // array to store nunchuck data,
  byte nunchuck_calib[16]; // calibration data
  
  unsigned int decodeByte(unsigned int x);
  void sendRequest();
  void extractData();
};
#endif